package com.wandian.weather.adapter;

import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mylib.libcore.utils.GlideUtil;
import com.mylib.libcore.utils.ScreenUtils;
import com.wandian.weather.R;
import com.wandian.weather.bean.XingZuoBean;

/**
 * 星座列表横向~
 */
public class ConstellationAdapter extends BaseQuickAdapter<XingZuoBean, BaseViewHolder> {

    private int screenWidth;

    public ConstellationAdapter(int layoutResId) {
        super(layoutResId);
        screenWidth = ScreenUtils.getScreenWidth(mContext);
    }

    @Override
    protected void convert(BaseViewHolder helper, XingZuoBean item) {
        LinearLayout mLlRootView = helper.getView(R.id.ll_root_view);
        ViewGroup.LayoutParams params = mLlRootView.getLayoutParams();
        params.width = screenWidth / 3;
        mLlRootView.setLayoutParams(params);

        ImageView mIvAge = helper.getView(R.id.img_xingzuo_pic);
        if (!TextUtils.isEmpty(item.getImg_path())) {
            mIvAge.setVisibility(View.VISIBLE);
            GlideUtil.into(mContext,item.getImg_path(),mIvAge);
        } else {
            mIvAge.setVisibility(View.INVISIBLE);
        }
        helper.setText(R.id.tv_xingzuo_title, item.getName())
                .setText(R.id.tv_xingzuo_date, item.getDate() + " " + item.getType());

    }

}
